package com.biz.primus.common.vo;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import lombok.Getter;
import lombok.Setter;

/**
 * @author david-liu
 */
@JsonPropertyOrder({"code", "status", "data", "message"})
@Getter
@Setter
public class MSSuccessResponseVO<T> extends MSResponseVO {
    private static final long serialVersionUID = 653242214546431477L;

    private T data;

    public MSSuccessResponseVO() {
    }

    public MSSuccessResponseVO(T data) {
        this.data = data;
    }

    public T getData() {
        return data;
    }

    public MSSuccessResponseVO<T> body(T data) {
        this.data = data;
        return this;
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder<T> {
        MSSuccessResponseVO<T> vo = new MSSuccessResponseVO<>();

        public Builder<T> status(String status) {
            vo.setStatus(status);
            return this;
        }

        public Builder<T> message(String message) {
            vo.setMessage(message);
            return this;
        }

        public Builder<T> code(int code) {
            vo.setCode(code);
            return this;
        }

        public Builder<T> body(T body) {
            vo.setData(body);
            return this;
        }

        public MSSuccessResponseVO<T> build() {
            return vo;
        }
    }

}
